package com.xiyi.shouxin.view.pojo;

import com.xiyi.shouxin.entity.admin.Admin;

import lombok.Getter;

@Getter
public class AdminView extends Admin {
    private RoleView role;

    public AdminView(Admin admin, RoleView roleView) {
        if (admin != null) {
            this.setId(admin.getId());
            this.setNickName(admin.getNickName());
            this.setAccount(admin.getAccount());
            this.setPassword(admin.getPassword());
            this.setRoleId(admin.getRoleId());
            this.setIsDelete(admin.getIsDelete());
        }
        this.role = roleView;
    }

    public Admin toAdmin() {
        Admin admin = new Admin();
        admin.setId(this.getId());
        admin.setNickName(this.getNickName());
        admin.setAccount(this.getAccount());
        admin.setPassword(this.getPassword());
        admin.setRoleId(this.getRoleId());
        admin.setIsDelete(this.getIsDelete());
        return admin;
    }
}
